define(['app'], function(app) {
	'use strict';

	//实例化方法
	var factory = function(Http) {

		/**
		 * 一键切换数据获取方式
		 * @param {Object} result
		 */
		function get_data_getlist(result) {
			if(HTTP_ISLOGIC) {
				result ='{"success":true,"msg":"","result":{"act":[{"act_id":"act_id_001","name":"新年促销","start_time":"2017/01/01 09:00:00","end_time":"2017/01/31 09:00:00","image":{"id":"001","image":"./img/upload/pro-img01.jpg"}},{"act_id":"act_id_002","name":"新年促销","start_time":"2017/01/01 09:00:00","end_time":"2017/01/31 09:00:00","image":{"id":"001","image":"./img/upload/pro-img01.jpg"}}]},"session":"7311da98bd0f18eb15a96bcb263f4153"}'			;
				return JSON.parse(result);
			} else {
				return result;
			}
		}

		//返回信息
		return {
			//取得登录用户对应的供应商列表
			getlist: function(from_type, nPage,status,callback,calldone) {
				Http.post({
						method: 'marketing.auction.getlist',
						from_type: from_type,
						picSize: 'CS',
						pagelimit: 10,
						nPage: nPage,
						status:status
					},
					function(result) {
						//请求成功
						if(callback)
							callback(get_data_getlist(result).result);
					},
					function(e) {
						//请求异常
					},
					function() {
						//请求完成，一般不做什么事情
						if(calldone)
                        calldone();

					}
				);
			},
			//获取首页数据
			get_adddiscount: function(callback) {
				//post请求
				Http.post('home', {}, function(result) {
					//函数回调
					if(callback)
						callback(result);
				});
			},
		};
	}

	factory.$inject = ['Http'];
	return app.registerService("Auctiontrade_agent", factory);
});
